//@author A0096759E

package testcases;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import storage.ScheduleEvent;
import storage.Storage;

public class StorageTestLoadFile {
	
	private static final String SUCCESS_ADDED_EVENT = "A task with the same task name exists already.\nThe event \"%s\" has been added successfully to your Schedule!";
	private static final String SUCCESS_ADDED_EVENT_1 = "The task is already added\nThe event \"%s\" has been added successfully to your Schedule!";
	private static final String SUCCESS_ADDED_EVENT_2 = "The event \"%s\" has been added successfully to your Schedule!";

	Storage storageTest = new Storage("JUnit Storage Load File Test.txt");
	
	@Test
	public void test() {
		
		if (storageTest.getSize() == 0) {
			assertEquals(String.format(SUCCESS_ADDED_EVENT_2, "TESTCASE haha" ),storageTest.addEvent(new ScheduleEvent(0, "TESTCASE haha", "22121991")));
			assertEquals(String.format(SUCCESS_ADDED_EVENT_2, "TESTCASE2 How is this?" ),storageTest.addEvent(new ScheduleEvent(1, "TESTCASE2 How is this?", "22121991", "1200")));
			assertEquals(String.format(SUCCESS_ADDED_EVENT_2, "TESTCASE" ),storageTest.addEvent(new ScheduleEvent(2, "TESTCASE", "22121991", "1200", "1230")));
			assertEquals(String.format(SUCCESS_ADDED_EVENT_2, "We need to remember to assert NO NULL Inputs" ),storageTest.addEvent(new ScheduleEvent(0, "We need to remember to assert NO NULL Inputs", "22121991")));
			
			storageTest.saveEvents();
		}
		
		assertEquals(String.format(SUCCESS_ADDED_EVENT, "TESTCASE haha" ),storageTest.addEvent(new ScheduleEvent(0, "TESTCASE haha", "22121991")));
		assertEquals(String.format(SUCCESS_ADDED_EVENT, "TESTCASE2 How is this?" ),storageTest.addEvent(new ScheduleEvent(1, "TESTCASE2 How is this?", "22121991", "1200")));
		assertEquals(String.format(SUCCESS_ADDED_EVENT_1, "TESTCASE" ),storageTest.addEvent(new ScheduleEvent(2, "TESTCASE", "22121991", "1200", "1230")));
		assertEquals(String.format(SUCCESS_ADDED_EVENT, "We need to remember to assert NO NULL Inputs" ),storageTest.addEvent(new ScheduleEvent(0, "We need to remember to assert NO NULL Inputs", "22121991")));
		
		storageTest.saveEvents();
	}

}
